import 'package:my_app/mock/goods_category.dart';
import 'package:dart_mock/dart_mock.dart' as mock;

class MockGoods {
  final int? categoryId;
  final String? characteristic;
  final int? originalPrice;
  final String? name;
  final String? pic;

  const MockGoods({
    this.categoryId,
    this.characteristic,
    this.originalPrice,
    this.name,
    this.pic
  });

  static List<MockGoods> _data = [];
  
  static data() {
    var category = MockGoodsCategory.data();
    if (_data.isEmpty) {
      for (var element in category) {
        var categoryId = category.indexOf(element);
        // 为每个分类生成5-15个商品
        List.generate(mock.integer(min: 5, max: 15), (index) {
          // 使用本地图片资源
          String imagePath = 'lib/assets/images/menu/goods${(index % 3) + 1}.png';
          _data.add(
            MockGoods(
              categoryId: categoryId,
              characteristic: mock.csentence(max: 36),
              originalPrice: mock.integer(min: 9, max: 99),
              name: mock.cword(max: 6),
              pic: imagePath
            ),
          );
        });
      }
    }

    return _data;
  }
}